package com.hyt.it.ogt.pj.feign.cloudefile;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.common.utils.exception.RemoteRequestExcepton;
import com.hyt.model.cloudefile.apiparams.PushTaskParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * feign客户端熔断器
 */
@Component
@Slf4j
public class PushTaskClientHystrix  implements FallbackFactory<PushTaskClient> {

    @Override
    public PushTaskClient create(Throwable throwable) {
        log.error("# PushTaskClientHystrix Hystrix message ", throwable);

        return new PushTaskClient() {
            @Override
            public ApiResponse<Boolean> pushTask(PushTaskParam pushTaskParam) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("调用失败");
            }
        };
    }
}
